<template>
	<view class="content">
		<view class="back">
			<m-icon type="arrowleft" size="28" class='btn-icon' @click="back()"></m-icon>
		</view>
		
        <view class="input-group">
			<view class="log-lable">
				<image :src="logo" mode="aspectFit" style="height: 200upx;"></image>
			</view>
        </view>
		
		<view class="qrcode-img">
			<image :src="qrcode"></image>
		</view>
		
		<view class="industry">{{version}}</view>
		
		<image src="../../static/currency/page.png" mode="" class="back_img"></image>
		
	</view>
</template>

<script>
    import service from '../../service.js';
	import mIcon from '../../components/m-icon/m-icon.vue';
	export default {
		computed: {
			i18n () {
				return this.$t('index')
			}
		},
		components: {
			mIcon
		},
		data() {
			return {
				token:uni.getStorageSync("token"),
				user:uni.getStorageSync('user'),
				qrcode: '',
				version:'',
				logo:''
			};
		},
		onShow:function(){
			uni.setNavigationBarTitle({
				title: this.i18n.pages.invite
			});
			self = this;
			self.logo = uni.getStorageSync('logo');
			uni.request({
				url: service.api.user.friends,
				method: 'GET',
				data: {
					"token":self.token
				},
				success: res => {
					var res = res.data;
					if (res.code == 1) {
						self.qrcode = res.data.qrcode;
						self.version = self.i18n.user.code + ':' + self.user.account;
					}else{
						uni.showModal({
							title: self.i18n.main.prompt,
							content: res.info,
							confirmText: self.i18n.main.confirm,
							confirmColor: '#FFAE00',
							cancelColor: '#D2D2D2',
							showCancel: false,
							success: function(res) {
								uni.switchTab({
									url: '/pages/main/user',
								});
							}
						});
					}
				}
			});
		},
		methods:{
			back(){
				uni.reLaunch({
					url: '/pages/main/user',
				});
			},
		}
	}
</script>

<style>
	.qrcode-img{
		margin-top: 54%;
	}
	.industry{
		margin-top: calc(54% + 400upx);
	}
</style>